package com.leosoft.heatmonitor.model;

import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.leosoft.heatmonitor.model.tool.JsonDateSerializer;

@Entity
@Table(name = "data", catalog = "heatMonitor")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Data implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7648385215879211106L;
	private String id;
	private String projectId;
	private String projectName;
	private String deviceKey;
	private String targetKey;
	private String building;
	private String door;
	private String user;
	private Double currentHeat;
	private Double totalHeat;
	private Double area;
	private Double currentPeriod;
	private Double totalPeriod;
	private Double realTemperature;
	private Double avgTemperature;
	private Double userTemperature;
	private Timestamp createtime;
	private Project project;

	@Column(name = "targetKey", nullable = false, length = 20)
	public String getTargetKey() {
		return targetKey;
	}

	public void setTargetKey(String targetKey) {
		this.targetKey = targetKey;
	}

	@Column(name = "currentHeat", nullable = true)
	public Double getCurrentHeat() {
		return currentHeat;
	}

	public void setCurrentHeat(Double currentHeat) {
		this.currentHeat = currentHeat;
	}

	@Column(name = "totalHeat", nullable = true)
	public Double getTotalHeat() {
		return totalHeat;
	}

	public void setTotalHeat(Double totalHeat) {
		this.totalHeat = totalHeat;
	}

	@Column(name = "area", nullable = true)
	public Double getArea() {
		return area;
	}

	public void setArea(Double area) {
		this.area = area;
	}

	@Column(name = "currentPeriod", nullable = true)
	public Double getCurrentPeriod() {
		return currentPeriod;
	}

	public void setCurrentPeriod(Double currentPeriod) {
		this.currentPeriod = currentPeriod;
	}

	@Column(name = "totalPeriod", nullable = true)
	public Double getTotalPeriod() {
		return totalPeriod;
	}

	public void setTotalPeriod(Double totalPeriod) {
		this.totalPeriod = totalPeriod;
	}

	@Column(name = "realTemperature", nullable = true)
	public Double getRealTemperature() {
		return realTemperature;
	}

	public void setRealTemperature(Double realTemperature) {
		this.realTemperature = realTemperature;
	}

	@Column(name = "avgTemperature", nullable = true)
	public Double getAvgTemperature() {
		return avgTemperature;
	}

	public void setAvgTemperature(Double avgTemperature) {
		this.avgTemperature = avgTemperature;
	}

	@Column(name = "userTemperature", nullable = true)
	public Double getUserTemperature() {
		return userTemperature;
	}

	public void setUserTemperature(Double userTemperature) {
		this.userTemperature = userTemperature;
	}

	@GenericGenerator(name = "generator", strategy = "uuid")
	@GeneratedValue(generator = "generator")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "projectid", nullable = false, length = 32)
	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "projectName", nullable = false, length = 30)
	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	@Column(name = "deviceKey", nullable = false, length = 20)
	public String getDeviceKey() {
		return deviceKey;
	}

	public void setDeviceKey(String deviceKey) {
		this.deviceKey = deviceKey;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonSerialize(using = JsonDateSerializer.class)
	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Timestamp createtime) {
		this.createtime = createtime;
	}

	@Column(name = "building", nullable = true, length = 20)
	public String getBuilding() {
		return building;
	}

	public void setBuilding(String building) {
		this.building = building;
	}

	@Column(name = "door", nullable = true, length = 20)
	public String getDoor() {
		return door;
	}

	public void setDoor(String door) {
		this.door = door;
	}

	@Column(name = "user", nullable = true, length = 20)
	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	@ManyToOne(targetEntity = Project.class)
	@JoinColumn(name = "projectId")
	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

}
